<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>发改局</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet"
        href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- IonIcons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
</head>

<body class="hold-transition sidebar-mini">
<div class="wrapper">

  <!-- 主内容容器 -->
  <div class="content-wrapper">
    <!-- 容器头标题 -->
    <div class="content-header">
      <div class="container-fluid">

        <div class="row mb-2">

          <div class="col-sm-6">
            <h1 class="m-0">查看政策文件</h1>
          </div>

          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">首页</a></li>
              <li class="breadcrumb-item active">查看政策文件</li>
            </ol>
          </div>

        </div>

      </div>

    </div>

    <!-- 主题内容正文 -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-12">
            <div class="card">

              <div class="card-body">


                <!-- 表格顶部企业搜索 -->
                <div class="form-group" style="display: flex;">
                  <label style="padding-top: 2px;">政策文件搜索</label>

                  <div class="navbar-search-block" style="margin-left: 20px;">
                    <form class="form-inline">
                      <div class="input-group input-group-sm">
                        <input class="form-control form-control-navbar" type="search" placeholder="请输入政策标题"
                               aria-label="Search" id="search">
                        <div class="input-group-append" style="margin-left: 10px;">
                          <button class="btn btn-navbar" type="button" onclick="search1()">
                            <i class="fas fa-search"></i>
                          </button>
                          <button class="btn btn-navbar" type="button" data-widget="navbar-search" onclick="clearSearch()">
                            <i class="fas fa-times"></i>
                          </button>

                        </div>
                        <div style="margin-left: 10px;">
                          <button type="button" class="btn btn-primary btn-sm" onclick="search1()">搜索</button>
                        </div>
                      </div>
                    </form>
                  </div>
                </div>


                <table id="example2" class="table table-bordered table-hover">
                  <thead>
                  <tr>
                    <th>标题</th>
                    <th>发布日期</th>
                    <th>在线预览</th>
                    <th>下载</th>
                    <th>操作</th>
                  </tr>
                  </thead>
                  <tbody>
                  </tbody>
                  <!-- <tfoot>
                      <tr>
                          <th>Rendering engine</th>
                          <th>Browser</th>
                          <th>Platform(s)</th>
                          <th>Engine version</th>
                          <th>CSS grade</th>
                      </tr>
                  </tfoot> -->
                </table>
              </div>

            </div>

          </div>

        </div>

      </div>

    </section>

  </div>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
  </aside>

  <!-- 版权信息 -->
  <footer class="main-footer">
    <strong>Copyright &copy; 2021 <a href="http://www.chengzhouyun.com/" target="_blank">ChengZhouYun</a>.</strong> All
    rights reserved.
    <div class="float-right d-none d-sm-inline-block">
      <b>Version</b> 1.0
    </div>
  </footer>

</div>

<!-- REQUIRED SCRIPTS -->
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE -->
<script src="../dist/js/adminlte.js"></script>

<!-- OPTIONAL SCRIPTS -->
<script src="../plugins/chart.js/Chart.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script src="../dist/js/pages/dashboard3.js"></script>
</body>
<!-- DataTables  & Plugins -->
<script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../../plugins/jszip/jszip.min.js"></script>
<script src="../../plugins/pdfmake/pdfmake.min.js"></script>
<script src="../../plugins/pdfmake/vfs_fonts.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<script src="../../plugins/moment/moment.min.js"></script>
<script>
  // 表格变量
  var table;

  // 表格搜索
  function search1()
  {
    table.ajax.reload();
  }

  // 搜索框清除内容
  function clearSearch() {
    $('#search').val('');
  }

  $(document).ready(function () {
    var arr_ids = new Array();

    // 表格数据展示配置  相关信息可以查看http://datatables.club/
    table = $('#example2').DataTable({
      processing : true,
      // 开启服务器端分页
      serverSide : true,
      sort: false,
      searchable: true,
      autoWidth: true,
      ajax:{
        type:"get",
        url:'/publishfile/list',
        dataSrc: 'data',
        data: function (param) {
          var search = $('#search').val();
          //添加参数传给服务器
          param.search = search;
          return param;
        }

      },
      // 渲染提高性能
      deferRender: true,
      // footerCallback: function(tfoot, data, start, end, display) {
      //
      // },
      columns:[
        // {data:"id",visible:false},
        {data:"title"},
        {data:"publishDate",
          "render" : function (data) {
            return moment(data).format("YYYY-MM-DD");
          }
        },
        {data:"filePath",
          "render":function(data, type,row){
            if(data == null){
              return "";
            }
            return "<a href='/page/preview/" + row.id +"'  target=\"_blank\">在线预览</a>"
          }
        },
        {data:"filePath",
          "render": function(data){
            if(data == null){
              return "";
            }
            return "<a href='" + data + "'  target=\"_blank\">下载</a>"
          }
        },
      ],
      "aoColumnDefs":[//设置列的属性，此处设置第一列不排序
        {"bSortable": false, "aTargets": [0]},{ "class": "tn", "targets": [ 0 ] },
        {
          "targets": 4,
          "class": "but_xq",
          "data": null,
          "bSortable": false,
          "render" : function(data, type,row) {
            // data 和 row 都是每行数据 里面存有id
            // var id = '"' + row.id + '"';

            var html = "<a href='/page/PolicyFileDetail/" + row.id + "' class='up btn btn-default btn-xs'><i class='fas fa-info-circle'></i>查看</a>"

            return html;
          }
        }
      ],


      // 显示语言
      "language": {
        zeroRecords:"没有匹配结果",
        emptyTable:"没有匹配结果",
        infoEmpty:"无符合条件记录",
        info: "显示第 _START_ 至 _END_ 条结果，共_TOTAL_条记录",
        lengthMenu: "每页显示 _MENU_ 条记录",
        paginate: {"first": "首页 ", "last": "末页", "next": "下一页", "previous": "上一页"}
      },

      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": true,
      "responsive": true,
    });

    // 移除搜索框的右边隐藏样式
    $('#search').removeClass("form-control-navbar")
  });
</script>

</html>
